<?php
// +----------------------------------------------------------------------
// | BB [ BB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024~2034 https://www.bobahappy.com.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: luowei Team <luowei@bobahappy.com>
// +----------------------------------------------------------------------

namespace app\dao\platform;

use app\dao\BaseDao;
use app\model\platform\${tableClass};

/**
 * ${tableComment}dao
 * Class ${tableClass}Dao
 * @package app\dao\platform
 */
class ${tableClass}Dao extends BaseDao
{
    /**
     * 设置模型
     * @return string
     */
    protected function setModel(): string
    {
        return ${tableClass}::class;
    }

	
	/**
	 * 获取列表
	 * @param array $where
	 * @return array
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\DbException
	 * @throws \think\db\exception\ModelNotFoundException
	 */
	public function getList($keywords, int $page, int $limit)
	{
	    $query = $this->getModel()->with([
	    <#list selfMethods as value>
		'${value.methodName}',
		</#list>
		])->where('is_del',0);
	    $query->when($keywords && $keywords !== '', function ($query) use ($keywords) {
	    	$query->whereLike('title', "%" . $keywords . "%");
	    });
	    $count = $query->count();
	    $list = $query->page($page, $limit)->order('id desc')->select();
	    return compact('count', 'list');
	}
	
	/**
	 * 导出数据
	 * @param array $where
	 * @return array
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\DbException
	 * @throws \think\db\exception\ModelNotFoundException
	 */
	public function exportData(array $where)
	{
	    return $this->search($where)->where('is_del',0)->order('id desc')->select()->toArray();
	}
	
	<#list methods as value>
	/**
	 * ${value.methodName}
	 * @param array $where
	 * @return array
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\DbException
	 * @throws \think\db\exception\ModelNotFoundException
	 */
	public function ${value.methodName}()
	{
	    return $this->search([])->field('${value.properties}')->where('is_del',0)->order('id desc')->select()->toArray();
	}	
	</#list>
	
}

